<template>
	<view class="detail">
		<view class="header">
			<text>{{goodsDetail.name}}</text>
		</view>
		<!-- 商品详情 -->
		<scroll-view class="detailScroll" scroll-y="true" >
			<image class="detailImg" :src="goodsDetail.listPicUrl" mode=""></image>
			<view class="tag">
				{{goodsDetail.promTag}}
			</view>
			<view class="price">
				￥ {{goodsDetail.counterPrice}}
			</view>
		</scroll-view>
		<!-- 底部 -->
		<view class="footer">
			<view class="footImg">
				<image class="Img" src="/static/images/tabBar/tab-my.png" mode=""></image>
			</view>
			<view class="footRight">
				<view class="btn">
					立即购买
				</view>
				<view class="btn cart" @click="addCart">
					加入购物车
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapMutations } from 'vuex';
	export default {
		data() {
			return {
				goodsDetail: {}
			};
		},
		onLoad(options) {
			// console.log(JSON.parse(options.goodsItem));
			this.goodsDetail = JSON.parse(options.goodsItem)
		},
		methods: {
			...mapMutations('cart', ['ADDGOODSITEM']),
			//加入购物车
			addCart() {
				this.ADDGOODSITEM(this.goodsDetail)
			}
		}
	}
</script>

<style lang="less">
	.detail {
		.header {
			width: 570rpx;
			height: 90rpx;
			line-height: 90rpx;
			text-align: center;
			margin: 0 auto;
		}
		.detailScroll {
			height: calc(100vh - 90rpx);
			.detailImg {
				width: 100%;
				height: 750rpx;
			}
			.tag {
				width: 90%;
				height: 100rpx;
				line-height: 100rpx;
				background-color: #bb2c08;
				text-align: center;
				margin: 20rpx auto;
				color: #fff;
				border-radius: 10rpx;
			}
			.price {
				font-size: 50rpx;
				color: #dd1a21;
				line-height: 70rpx;
				margin-left: 5%;
			}
		}
		.footer {
			height: 100rpx;
			width: 100%;
			line-height: 100rpx;
			display: flex;
			position: fixed;
			bottom: 0;
			left: 0;
			border-top: 1rpx solid #ddd;
			// background-color: red;
			.footImg {
				width: 150rpx;
				height: 100%;
				border-right: 1rpx solid #ddd;
				.Img {
					width: 60rpx;
					height: 60rpx;
					margin: 20rpx 40rpx;
				}
			}
			.footRight {
				display: flex;
				flex: 1;
				.btn {
					flex: 1;
					text-align: center;
					// background-color: pink;
				}
				.cart {
					color: #fff;
					background-color: #bb2c08;
				}
			}
		}
	}
</style>
